import React from 'react'
import {Redirect, Route} from "react-router-dom"
import {useStore} from '../store'

export default function PrivateRoute({component: Component, ...rest}) {
  console.log('rest', rest)
  const store = useStore()
  return (
    <Route {...rest} render={(props) => {
      return store.userStore.isLogin ? <Component {...props} /> : <Redirect to={{
        pathname: "/login",
        state: {redirect: props.location}
      }}></Redirect>
    }}></Route>
  )
}
